		var items;
		var citys;
		var page=1;
		var nextPage=2;
		var prePage=1;
		var totalPage;
		var pageSize=10;
		var currentPage=1;
		var length;
		var carrierArry=new Array();
		var map = {};
		
		Array.prototype.delRepeat=function(){  
			     var newArray=[];  
			     var provisionalTable = {};  
			     for (var i = 0, item; (item= this[i]) != null; i++) {  
			         if (!provisionalTable[item]) {  
			             newArray.push(item);  
			             provisionalTable[item] = true;  
			         }  
			     }  
			     return newArray;  
			 }; 

$(function() {
		 $("#searchFlight").click(function() { //按钮单击事件
							//打开文件，并通过回调函数处理获取的数据
							d = new Date(); // 创建 Date 对象。 
							s="temp";
							s += d.getYear() ; // 获取年份。 
							s += d.getMonth()+1 ; // 获取月份。 
							s += d.getDate(); // 获取日。 
							s += d.getHours(); // 获取小时。
							s += d.getMinutes(); // 获取分钟。
							s += d.getSeconds(); // 获取秒数。
							$('.both').remove();
							$.ajax({
								type : "Post",
								url : __ctxPath
										+ "/front/order/orderSearch.do?cmd=getApointName&flightName='广州'&arriName='上海'&tempVar="+s,
								dataType : "String",
								async:false,
								success : function(data) {
									citys=eval(data);
								},
								error : function() {
									alert('获取城市名称失败!');
								}
							});
							$.ajax({
										type : "GET",
										url : __ctxPath
												+ "/front/order/orderSearch.do?cmd=searchOrder&tempVar="+s,
//										dataType : "json",
										dataType : "string",
										success : function(data) {
//											items=data.childNodes;
											items=eval(test).childNodes;
										
											length=items.length;
											page=1;
											nextPage=2;
											prePage=1;
											totalPage;
											pageSize=10;
											currentPage=1;
											var total=page*pageSize;
											
											//去重航空公司二字码
											 for(var i=0;i<items.length;i++){
													var carrier=items[i].childNodes[22].childNodes;
													carrierArry.push(carrier);
													}
											 carrierArry=carrierArry.delRepeat();
											 
											 //过滤后的航空公司对应航班
											 for ( var int = 0; int < carrierArry.length; int++) {
												 var carrierMapValue=new Array();
												 for(var j=0;j<items.length;j++){
														var carrierValue=items[j];
														if(carrierValue.childNodes[22].childNodes.toString()==carrierArry[int].toString()){
														carrierMapValue.push(carrierValue);
														}
													}
												 map[carrierArry[int]]=carrierMapValue;
											}
											 for ( var x = 0; x < carrierArry.length; x++) {
//												alert(map[carrierArry[x]].length);
											}
											totalPage=Math.round((items.length-2)/10);
											
											$("#fligtCode tr").remove(); 

											var tr_str="<tr>";   
							                tr_str+="<td width='16%'>仅显示：<a href='#'><font color='#FF0000'>全部</font></a></td>";   
							                for ( var int = 0; int < carrierArry.length; int++) {
							                	tr_str+="<td width='12%'><a href='filterCarrier("+carrierArry[int]+")'>"+carrierArry[int]+"</a></td>";   
							            	}
							                tr_str+="</tr>";
							                $("#fligtCode").append(tr_str); 
							            
											createHtml();
											
										},
										error : function() {
											alert('失败!');
										}
									});
						}); 
	});
	
	function next(){
		page+=1;
		createHtml();
	}
	
	
	function pre(){
		alert(page);
		page=parseInt(page)-1;
		
		createHtml();
	}

	function filterCarrier(selectCarrier){
		var selectItem=map[selectCarrier];
		createHtml(selectItem);
	}
	function createHtml(selectItem){
		
		$('.both').remove();
		var html="<div class='both'> ";
		var total=page*pageSize;
		 for(currentPage;currentPage<=total;currentPage++){
			 if(currentPage<length){
				 
			var carrier=items[currentPage].childNodes[22].childNodes;
			var flight=items[currentPage].childNodes[12].childNodes;
			var duptDate=items[currentPage].childNodes[14].childNodes;
			var arrivalDate=items[currentPage].childNodes[4].childNodes;
			var duptTime=items[currentPage].childNodes[6].childNodes;
			var ariTime=items[currentPage].childNodes[13].childNodes;
			var boardPoint=items[currentPage].childNodes[8].childNodes;
			var offPoint=items[currentPage].childNodes[7].childNodes;
			var flightTime=items[currentPage].childNodes[16].childNodes;
			var tpm=items[currentPage].childNodes[11].childNodes;
			var stop=items[currentPage].childNodes[24].childNodes;
			

			var boardPointName=items[currentPage].childNodes[8].childNodes;
			var offPointName=items[currentPage].childNodes[7].childNodes;
			for(var city in citys){
				if(boardPointName==citys[city].name){
					boardPointName=citys[city].value;
						break;
				}
			}	
			for(var city in citys){
				if(offPointName==citys[city].name){
					offPointName=citys[city].value;
					break;
				} 
			}
			var yPrice=items[currentPage].childNodes[20].childNodes;
			var airportTax=items[currentPage].childNodes[0].childNodes;

			//if(carrier=='CZ'){
			html+="<div id=\"content\">"
          	+"<div id=\"list\">"
          	+"<div class=\"t0\"><img src="+__ctxPath+"/resource/front/image/newpic/CZ.gif /></div>"
          	+"<div class=\"t1\">中国南方航空公司<br /><span>"+carrier+flight+"</span></div>"
          	+"<div class=\"t2\">"+duptTime+"<br /><span>"+ariTime+"</span></div>"
          	+" <div class=\"t3\">"+boardPointName+"<br /><span>"+offPointName+"	</span></div>"
          	+"<div class=\"t4\">"+yPrice+"<span>/"+yPrice+"舱</span></div>"
          	+" <div class=\"t5\" >"
          	+"<a href=\"#\"title=\"更改条件:需每次收取票面价10%的改签费<br>退票条件:需收取票面价20%的退票费<br>签转条件:不允许签转\">退改签</a>"
          	+"</div>"
          	+"<div class=\"t6\">￥50/￥180</div>  "
          	+"<div class=\"t7\"><a href="+__ctxPath+"/front/order/orderSearch.do?cmd=bookin&" +
          			"flight="+flight+"&carrier="+carrier+"&cabin=M&departure_day="+duptDate+"&duptTime="+duptTime+"&ariTime="+ariTime+"" +
          					"&tmp="+tpm+"&flyTime="+flightTime+"&boardPointName="+boardPointName+"&offPointName="+offPointName+"&price=100" +
          							"&departure_city="+boardPoint+"&arrival_city="+offPoint+"&stop="+stop+"></a></div> "
          	+"</div>"
			+"<a class=\"button\" onclick=\"senfe(this);\">展开舱位>></a>";
          		var classes=items[currentPage].childNodes[1].childNodes;
        		var innerHtml="";
				if (typeof(classes) != "undefined") { 
		
				for ( var index = 0; index < classes.length; index++) {
					var obj=classes[index].childNodes;
					var price=obj[0].childNodes;
					var cabin=obj[3].childNodes;
					innerHtml+="<div id=\"list\">"
	          	+" <div class=\"t0\"></div>"
	          	+" <div class=\"t1\"></div>"
	          	+" <div class=\"t2\"></div>"
	          	+"<div class=\"t3\"></div>"
	          	+"<div class=\"t4\">￥"+price+"<span>/"+cabin+"舱</span></div>"
	          	+" <div class=\"t5\" ><a href=\"#\"title=\"更改条件:需每次收取票面价10%的改签费<br>退票条件:需收取票面价20%的退票费<br>签转条件:不允许签转\">退改签</a></div>"
	          	+"<div class=\"t6\">￥"+airportTax+"/￥"+price+"</div>"
	          	+" <div class=\"t7\"><a href=\"international_bookin.htm\"></a></div> "
	          	+"</div>";
				}	
			}
          	
			html+=innerHtml+"<div id=\"end\">里程"+tpm+"公里 | 历时："+flightTime+"小时 | 经停："+stop+"</div></div>";
        	 }else{
				 break;
			 }
		}
		//	}
		//});
		 alert(html);
		  html+="</div> ";
		 $('.flightlist').after(html);
	}